package com.aspose.cells;

final class zbsq {
   private static final com.aspose.cells.b.c.a.za a = new com.aspose.cells.b.c.a.za(new String[]{"(", ")", "[", "]", "{", "}", "<", ">", "（", "）", "《", "》"});

   public static void a(zn var0, com.aspose.cells.b.a.b.zp var1, String var2, int var3, com.aspose.cells.b.a.b.zg var4, Color var5, int var6, int var7, int var8) {
      com.aspose.cells.b.a.b.zq var9 = new com.aspose.cells.b.a.b.zq((float)var1.c(), (float)var1.d(), (float)var1.e(), (float)var1.f());
      a(var0, var9, var2, var3, var4, var5, var6, var7, var8);
   }

   public static void a(zn var0, com.aspose.cells.b.a.b.zq var1, String var2, int var3, com.aspose.cells.b.a.b.zg var4, Color var5, int var6, int var7, int var8) {
      com.aspose.cells.b.a.b.zv var9 = new com.aspose.cells.b.a.b.zv();
      var9.a(a(var6));
      var9.c(a(var7));
      switch(Math.abs(var3)) {
      case 0:
         var0.a(var2, var4, new com.aspose.cells.b.a.b.zu(var5), (com.aspose.cells.b.a.b.zq)var1, var9);
         break;
      case 90:
         var0.b(var1.j() + var1.h() / 2.0F, var1.k() + var1.i() / 2.0F);
         var0.a((float)(-var3));
         var1 = new com.aspose.cells.b.a.b.zq(-var1.i() / 2.0F, -var1.h() / 2.0F, var1.i(), var1.h());
         var0.a(var2, var4, new com.aspose.cells.b.a.b.zu(var5), (com.aspose.cells.b.a.b.zq)var1, var9);
         var0.d();
         break;
      case 255:
         a(var0, var2, var4, var5, var1.f(), var1.g(), var1.h(), var1.i(), var8);
         break;
      default:
         double var10 = Math.sqrt(Math.pow((double)var1.h(), 2.0D) + Math.pow((double)var1.i(), 2.0D));
         var9.b(4096);
         com.aspose.cells.b.a.b.zt var12 = var0.a(var2, var4, (int)var10, var9);
         var0.b(var1.j() + var1.h() / 2.0F, var1.k() + var1.i() / 2.0F);
         var0.a((float)(-var3));
         com.aspose.cells.b.a.b.zq var13 = new com.aspose.cells.b.a.b.zq(-var12.b() / 2.0F, -var12.c() / 2.0F, var12.b(), var12.c());
         var0.a(var2, var4, new com.aspose.cells.b.a.b.zu(var5), (com.aspose.cells.b.a.b.zq)var13, var9);
         var0.d();
      }

   }

   public static com.aspose.cells.b.a.b.zs a(zn var0, String var1, int var2, com.aspose.cells.b.a.b.zg var3, com.aspose.cells.b.a.b.zs var4, int var5, int var6) {
      com.aspose.cells.b.a.b.zt var7 = new com.aspose.cells.b.a.b.zt((float)var4.b(), (float)var4.c());
      return a(var0, var1, var2, var3, var7, var5, var6);
   }

   public static com.aspose.cells.b.a.b.zs a(zn var0, String var1, int var2, com.aspose.cells.b.a.b.zg var3, com.aspose.cells.b.a.b.zt var4, int var5, int var6) {
      if (var1.endsWith("\n")) {
         var1 = var1 + " ";
      }

      com.aspose.cells.b.a.b.zs var7 = a(var0, var1, var3, var4, var5, var6);
      switch(Math.abs(var2)) {
      case 0:
         return var7;
      case 90:
         com.aspose.cells.b.a.b.zs var8 = a(var0, var1, var3, new com.aspose.cells.b.a.b.zt((float)((int)var4.c()), (float)((int)var4.b())), var5, var6);
         return new com.aspose.cells.b.a.b.zs(var8.c(), var8.b());
      case 255:
         com.aspose.cells.b.a.b.zs var9 = a(var0, "H", var3);
         if (var4.b() >= (float)var9.b() && var4.c() >= (float)var9.c()) {
            boolean var10 = false;
            boolean var11 = false;
            int var12 = (int)(var4.c() / (float)var9.c());
            int var13 = (int)(var4.b() / (float)var9.b());
            int var14 = (int)Math.ceil((double)((float)var1.length() / (float)var12));
            int var16;
            int var17;
            if (var12 >= var1.length()) {
               var17 = var1.length() * var9.c();
               var16 = var9.b();
            } else {
               if (var14 <= var13) {
                  var16 = var9.b() * var14;
               } else {
                  var16 = var9.b() * var13;
               }

               var17 = var9.c() * var12;
            }

            return new com.aspose.cells.b.a.b.zs(var16, var17);
         }

         return new com.aspose.cells.b.a.b.zs(0, 0);
      default:
         com.aspose.cells.b.a.b.zt var15 = var0.a(var1, var3, new com.aspose.cells.b.a.b.zo(0.0F, 0.0F), new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c()));
         return a(var15, var4, Math.abs(var2));
      }
   }

   private static com.aspose.cells.b.a.b.zs a(zn var0, String var1, com.aspose.cells.b.a.b.zg var2, com.aspose.cells.b.a.b.zt var3, int var4, int var5) {
      com.aspose.cells.b.a.b.zv var6 = new com.aspose.cells.b.a.b.zv();
      var6.a(a(var4));
      var6.c(a(var5));
      com.aspose.cells.b.a.b.zt var7 = var0.a(var1, var2, var3, var6);
      int var8 = zbuk.a((double)var7.b());
      int var9 = zbuk.a((double)var7.c());
      return new com.aspose.cells.b.a.b.zs(var8, var9);
   }

   private static com.aspose.cells.b.a.b.zs a(com.aspose.cells.b.a.b.zt var0, com.aspose.cells.b.a.b.zt var1, int var2) {
      double var3 = (double)Math.abs(var2 % 90) / 180.0D * 3.141592653589793D;
      double var5 = (double)var0.b() * Math.cos(var3) + (double)var0.c() * Math.sin(var3);
      double var7 = (double)var0.b() * Math.sin(var3) + (double)var0.c() * Math.cos(var3);
      if (var5 > (double)var1.b()) {
         var7 = (double)var1.b() * var7 / var5;
         var5 = (double)var1.b();
      }

      if (var7 > (double)var1.c()) {
         var5 = (double)var1.c() * var5 / var7;
         var7 = (double)var1.c();
      }

      return new com.aspose.cells.b.a.b.zs(zbuk.a(var5), zbuk.a(var7));
   }

   static com.aspose.cells.b.a.b.zs a(zn var0, String var1, com.aspose.cells.b.a.b.zg var2) {
      com.aspose.cells.b.a.b.zt var3 = var0.a(var1, var2);
      int var4 = zbuk.a((double)var3.b());
      int var5 = zbuk.a((double)var3.c());
      return new com.aspose.cells.b.a.b.zs(var4, var5);
   }

   public static com.aspose.cells.b.a.b.zs b(zn var0, String var1, int var2, com.aspose.cells.b.a.b.zg var3, com.aspose.cells.b.a.b.zs var4, int var5, int var6) {
      com.aspose.cells.b.a.b.zt var7 = new com.aspose.cells.b.a.b.zt((float)var4.b(), (float)var4.c());
      return b(var0, var1, var2, var3, var7, var5, var6);
   }

   public static com.aspose.cells.b.a.b.zs b(zn var0, String var1, int var2, com.aspose.cells.b.a.b.zg var3, com.aspose.cells.b.a.b.zt var4, int var5, int var6) {
      switch(Math.abs(var2)) {
      case 0:
         com.aspose.cells.b.a.b.zs var7 = b(var0, var1, var3, var4, var5, var6);
         return var7;
      case 90:
         com.aspose.cells.b.a.b.zs var8 = b(var0, var1, var3, new com.aspose.cells.b.a.b.zt((float)((int)var4.c()), (float)((int)var4.b())), var5, var6);
         return new com.aspose.cells.b.a.b.zs(var8.c(), var8.b());
      default:
         com.aspose.cells.b.a.b.zt var9 = var0.a(var1, var3, new com.aspose.cells.b.a.b.zo(0.0F, 0.0F), new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c()));
         return a(var9, var4, Math.abs(var2));
      }
   }

   private static com.aspose.cells.b.a.b.zs b(zn var0, String var1, com.aspose.cells.b.a.b.zg var2, com.aspose.cells.b.a.b.zt var3, int var4, int var5) {
      com.aspose.cells.b.a.b.zv var6 = new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c());
      var6.b(var6.d() | 2048);
      var6.a(a(var4));
      var6.c(a(var5));
      com.aspose.cells.b.a.b.zt var7 = var0.a(var1, var2, var3, var6);
      int var8 = zbuk.a((double)var7.b());
      int var9 = zbuk.a((double)var7.c());
      return new com.aspose.cells.b.a.b.zs(var8, var9);
   }

   public static com.aspose.cells.b.a.b.zt b(zn var0, String var1, com.aspose.cells.b.a.b.zg var2) {
      com.aspose.cells.b.a.b.zv var3 = new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c());
      var3.b(var3.d() | 2048);
      com.aspose.cells.b.a.b.zt var4 = var0.a(var1, var2, Integer.MAX_VALUE, var3);
      int var5 = zbuk.a((double)var4.b());
      int var6 = zbuk.a((double)var4.c());
      return new com.aspose.cells.b.a.b.zt((float)var5, (float)var6);
   }

   private static com.aspose.cells.b.a.b.zt a(zn var0, String var1, com.aspose.cells.b.a.b.zg var2, com.aspose.cells.b.a.b.zs var3) {
      com.aspose.cells.b.a.b.zt var4 = new com.aspose.cells.b.a.b.zt((float)var3.b(), (float)var3.c());
      return a(var0, var1, var2, var4);
   }

   private static com.aspose.cells.b.a.b.zt a(zn var0, String var1, com.aspose.cells.b.a.b.zg var2, com.aspose.cells.b.a.b.zt var3) {
      var3 = new com.aspose.cells.b.a.b.zt(var3.b(), var3.c());
      int var4 = zbuk.a((double)var0.a().a(var2));
      if (var1 != null && var1.length() != 0) {
         com.aspose.cells.b.a.g.a.ze var5 = new com.aspose.cells.b.a.g.a.ze("\\n");
         com.aspose.cells.b.a.g.a.ze var6 = new com.aspose.cells.b.a.g.a.ze("^\\s{1,}$");
         if (!var6.d(var1) && var6.d(var1.substring(var1.length() - 1))) {
            var1 = var1 + "|";
         }

         if (!var5.d(var1) && var6.d(var1)) {
            com.aspose.cells.b.a.b.zt var18 = var0.a(var1, var2, new com.aspose.cells.b.a.b.zo(0.0F, 0.0F), new com.aspose.cells.b.a.b.zv(2048));
            if (var18.c() > (float)var4 * 1.5F) {
               return var18;
            } else {
               String var19 = "aaaaaaaaaa";
               String var20 = var19 + var1 + var19;
               com.aspose.cells.b.a.b.zt var21 = new com.aspose.cells.b.a.b.zt(2.14748365E9F, 2.14748365E9F);
               com.aspose.cells.b.a.b.zt var22 = a(var0, var19, var2, var21);
               com.aspose.cells.b.a.b.zt var23 = a(var0, var20, var2, var21);
               float var24 = var23.b() - 2.0F * var22.b() > 0.0F ? var23.b() - 2.0F * var22.b() : (float)var4 / 5.0F;
               return new com.aspose.cells.b.a.b.zt(var24, var18.c());
            }
         } else {
            com.aspose.cells.b.a.b.zv var7 = new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c());
            var7.b(var7.d() | 2048);
            com.aspose.cells.b.a.b.zt var8 = var0.a(var1, var2, var3, var7);
            boolean var9 = false;
            if (var8.c() < (float)var4 * 1.5F) {
               var1 = var1 + "|";
               var3.a(var3.b() + (float)var4);
               var8 = var0.a(var1, var2, var3, var7);
               var9 = true;
            }

            int var10 = zbuk.a((double)var8.c());
            if (var10 >= 1 && var8.b() >= 1.0F) {
               int var11 = (int)((double)var8.b() * 0.1D);
               if (var11 < 10) {
                  var11 = 10;
               }

               com.aspose.cells.b.a.b.za var12 = new com.aspose.cells.b.a.b.za(var11, var10);
               com.aspose.cells.b.a.b.zi var13 = com.aspose.cells.b.a.b.zi.a((com.aspose.cells.b.a.b.zj)var12);
               float var14 = (float)zbuk.a((double)var8.b());
               if (!var9) {
                  var13.a(Color.getWhite());
                  com.aspose.cells.b.a.b.zq var15 = new com.aspose.cells.b.a.b.zq((float)var11 - var14, 0.0F, var14, (float)var10);
                  var13.a(var1, var2, com.aspose.cells.b.a.b.zd.a(), var15, var7);

                  for(int var16 = var11 - 1; var16 >= 0; --var16) {
                     --var14;

                     int var17;
                     for(var17 = 0; var17 < var10 && (var12.a(var16, var17).getR() & 255) == 255; ++var17) {
                        ;
                     }

                     if (var17 < var10) {
                        ++var14;
                        break;
                     }
                  }
               } else {
                  var13.a(Color.getWhite());
                  var13.a(var1, var2, com.aspose.cells.b.a.b.zd.a(), (float)var11 - var14, 0.0F, var7);

                  for(int var25 = var11 - 1; var25 >= 0; --var25) {
                     --var14;
                     if ((var12.a(var25, var4 / 2).getR() & 255) != 255) {
                        break;
                     }
                  }
               }

               if (var12 != null) {
                  var12.d();
               }

               if (var13 != null) {
                  var13.e();
               }

               if (var14 < 0.0F) {
                  var14 = var8.b();
               }

               return new com.aspose.cells.b.a.b.zt(var14, (float)var10);
            } else {
               return var8;
            }
         }
      } else {
         return new com.aspose.cells.b.a.b.zt(0.0F, (float)var4);
      }
   }

   public static int a(int var0) {
      if (var0 == 1) {
         return 1;
      } else if (var0 != 7 && var0 != 9) {
         return var0 != 0 && var0 != 8 ? 1 : 2;
      } else {
         return 0;
      }
   }

   public static float a(zn var0, String var1, com.aspose.cells.b.a.b.zg var2, boolean var3) {
      com.aspose.cells.b.a.g.a.ze var4 = new com.aspose.cells.b.a.g.a.ze("\\s+");
      String[] var5 = var4.c(var1);
      float var6 = 0.0F;

      for(int var7 = 0; var7 < var5.length; ++var7) {
         com.aspose.cells.b.a.b.zt var8;
         if (var3) {
            var8 = zbuk.a(a(var0, var5[var7], var2));
         } else {
            var8 = var0.a(var5[var7], var2);
         }

         if (var8.b() > var6) {
            var6 = var8.b();
         }
      }

      return var6;
   }

   public static com.aspose.cells.b.a.b.zt c(zn var0, String var1, com.aspose.cells.b.a.b.zg var2) {
      com.aspose.cells.b.a.b.zs var3 = new com.aspose.cells.b.a.b.zs(Integer.MAX_VALUE, Integer.MAX_VALUE);
      com.aspose.cells.b.a.b.zs var4 = a(var0, var1, var2);
      com.aspose.cells.b.a.b.zt var5 = a(var0, var1, var2, var3);
      return new com.aspose.cells.b.a.b.zt((float)var4.b() - var5.b(), (float)var4.c() - var5.c());
   }

   public static void a(zn var0, String var1, com.aspose.cells.b.a.b.zg var2, Color var3, float var4, float var5, float var6, float var7, int var8) {
      com.aspose.cells.b.a.b.zs var9 = a(var0, "H", var2);
      int var10 = (int)(var7 / (float)var9.c());
      int var11 = (int)(var6 / (float)var9.b());
      com.aspose.cells.b.a.b.zu var12 = new com.aspose.cells.b.a.b.zu(var3);

      try {
         float var13 = var4;
         if (var8 == 2) {
            var13 = var4 + var6 - (float)var9.b();
         }

         for(int var15 = 0; var15 < var11; ++var15) {
            float var14 = var5;
            int var16;
            if (var15 == var11 - 1 && var15 != 0) {
               var16 = var1.length() % var10;
               if (var16 != 0) {
                  var14 = var5 + (float)((var10 - var16) * var9.c() / 2);
               }
            }

            for(var16 = 0; var16 < var10; ++var16) {
               int var17 = var15 * var10 + var16;
               if (var17 >= var1.length()) {
                  break;
               }

               String var18 = var1.substring(var17, var17 + 1);
               com.aspose.cells.b.a.b.zt var19 = var0.a(var18, var2);
               if (a(var18)) {
                  var0.b(var13 + (float)(var9.b() / 2), var14 + (float)(var9.c() / 2));
                  var0.a(90.0F);
                  var0.a(var18, var2, var12, (float)(-var9.b() / 2), (float)(-var9.c() / 2));
                  var0.d();
               } else {
                  var0.a(var18, var2, var12, var13 - (var19.b() - (float)var9.b()) / 2.0F, var14);
               }

               var14 += (float)var9.c();
            }

            if (var8 == 2) {
               var13 -= (float)var9.b();
            } else {
               var13 += (float)var9.b();
            }
         }
      } finally {
         if (var12 != null) {
            var12.f();
         }

      }

   }

   private static boolean a(String var0) {
      switch(a.a(var0)) {
      case 0:
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      case 7:
      case 8:
      case 9:
      case 10:
      case 11:
         return true;
      default:
         return false;
      }
   }
}
